<?php
require_once 'pworks/mvc/result/PageXMLCfgLoader.class.php';

class PageConfigHelper
{
	public static $cacheHelper;
	public static $pageConf;

	public function init($filename)
	{
		$flag_key = 'CONF_INIT_FLAG'.$filename;
		$conf_key = 'CONF_DATA'.$filename;

		if (!self::$cacheHelper->fetch($flag_key)) {
			$loader = new PageXMLCfgLoader;
			$loader->load($filename);
			self::$pageConf = $loader->getConfig();
			self::$cacheHelper->store($flag_key, TRUE);
			self::$cacheHelper->store($conf_key, self::$pageConf);
		} else {
			self::$pageConf = self::$cacheHelper->fetch($conf_key);
		}
	}
	
	public function getPageConfig($page_id)
	{
        return self::$pageConf->$page_id;
	}

    public function getPageBaseDir()
    {
        return self::$pageConf->BASE_DIR;
    }
}

